<?php

/**
 * LacunasTentativas
 *  
 * @author diego
 * @version 
 */

require_once 'Zend/Db/Table/Abstract.php';

class Recursos extends Zend_Db_Table_Abstract {

	protected $_name = 'tex_recursos';
	
    protected $_referenceMap    = array(
        'Textos' => array(
            'columns'           => array('id_texto'),
            'refTableClass'     => 'Textos',
            'refColumns'        => array('id'),
            'onDelete'          => self::CASCADE,
            'onUpdate'          => self::RESTRICT
        )
        
    );
	
    /**
     * Pega os recursos de um texto
     * 
     * @param int texto
     * @return Zend_Db_Table_Rowset_Abstract
     */
	public function findbyTexto($texto) {
		return $this->fetchAll ( $this->getAdapter ()->quoteInto ( 'id_texto = ?', $texto ) );
	}
	
	/**
	 * 
	 * @param int recurso, int  texto
	 * @return Zend_Db_Table_Rowset_Abstract
	 */
	public function findByRecursoAndTexto($recurso, $texto) {
		return $this->fetchAll ( $this->getAdapter ()->quoteInto ( 'recurso = ?', $recurso) . " and ".
		 $this->getAdapter ()->quoteInto ( 'id_texto = ?', $texto ) );
	}
		
	public function deleteByRecurso($texto, $recurso) {
		parent::delete ( $this->getAdapter ()->quoteInto ( 'id_texto = ?', $texto ) . ' and ' . $this->getAdapter ()->quoteInto ( 'recurso = ?', $recurso ) );
	}
  
   /* public function findByLacunaAndUsuario($lacuna, $usuario) {
      	return $this->fetchRow( $this->getAdapter()->quoteInto('id_lacuna = ?', $lacuna). ' and '.
    	$this->getAdapter()->quoteInto('id_usuario = ?', $usuario));
    }
    
 	public function update(array $dados, $lacuna) {
    	parent::update($dados, $this->getAdapter()->quoteInto('id_lacuna = ?', $lacuna). ' and '.
    	$this->getAdapter()->quoteInto('id_usuario = ?', $dados['id_usuario']));
    }

    */
}
